// Mock data for development and testing
const { v4: uuidv4 } = require('crypto');

const mockUsers = [
  {
    id: '1',
    username: 'admin',
    email: 'admin@example.com',
    password: '$2a$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
    role: 'admin',
    createdAt: '2024-01-01T00:00:00.000Z'
  },
  {
    id: '2',
    username: 'developer',
    email: 'dev@example.com',
    password: '$2a$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
    role: 'developer',
    createdAt: '2024-01-15T00:00:00.000Z'
  }
];

const mockDatabases = [
  {
    id: 'db-1',
    name: 'production-aurora',
    engine: 'Aurora PostgreSQL',
    version: '15.4',
    status: 'running',
    region: 'us-east-1',
    instanceType: 'db.r5.xlarge',
    storage: 250,
    connections: 45,
    cpu: 68,
    memory: 72,
    createdAt: '2024-01-15T08:30:00.000Z',
    updatedAt: '2024-01-15T08:30:00.000Z'
  },
  {
    id: 'db-2',
    name: 'analytics-mysql',
    engine: 'MySQL',
    version: '8.0.35',
    status: 'running',
    region: 'us-west-2',
    instanceType: 'db.r5.large',
    storage: 100,
    connections: 23,
    cpu: 42,
    memory: 38,
    createdAt: '2024-02-20T10:15:00.000Z',
    updatedAt: '2024-02-20T10:15:00.000Z'
  },
  {
    id: 'db-3',
    name: 'development-db',
    engine: 'PostgreSQL',
    version: '14.9',
    status: 'stopped',
    region: 'us-east-1',
    instanceType: 'db.t3.medium',
    storage: 50,
    connections: 0,
    cpu: 0,
    memory: 0,
    createdAt: '2024-03-10T14:22:00.000Z',
    updatedAt: '2024-03-10T14:22:00.000Z'
  },
  {
    id: 'db-4',
    name: 'staging-redis',
    engine: 'Redis',
    version: '7.0.12',
    status: 'running',
    region: 'eu-west-1',
    instanceType: 'cache.r6g.large',
    storage: 25,
    connections: 12,
    cpu: 25,
    memory: 45,
    createdAt: '2024-03-15T09:45:00.000Z',
    updatedAt: '2024-03-15T09:45:00.000Z'
  }
];

const mockSlowQueries = [
  {
    id: 'query-1',
    query: 'SELECT * FROM orders o JOIN users u ON o.user_id = u.id WHERE o.created_at > \'2024-01-01\' ORDER BY o.total_amount DESC',
    duration: 4.25,
    database: 'production-aurora',
    timestamp: '2024-03-15T10:30:00.000Z',
    impact: 'high',
    executionCount: 156,
    avgDuration: 3.8
  },
  {
    id: 'query-2',
    query: 'UPDATE user_sessions SET last_activity = NOW() WHERE user_id IN (SELECT id FROM users WHERE active = true)',
    duration: 2.15,
    database: 'analytics-mysql',
    timestamp: '2024-03-15T10:25:00.000Z',
    impact: 'medium',
    executionCount: 89,
    avgDuration: 1.9
  },
  {
    id: 'query-3',
    query: 'SELECT COUNT(*) FROM analytics_events WHERE event_type = \'page_view\' AND created_at BETWEEN \'2024-03-01\' AND \'2024-03-15\'',
    duration: 1.85,
    database: 'analytics-mysql',
    timestamp: '2024-03-15T10:20:00.000Z',
    impact: 'low',
    executionCount: 45,
    avgDuration: 1.6
  }
];

const mockMetrics = [
  // Last 24 hours of data points (every hour)
  ...Array.from({ length: 24 }, (_, i) => ({
    timestamp: new Date(Date.now() - (23 - i) * 60 * 60 * 1000).toISOString(),
    cpu: Math.random() * 30 + 40, // 40-70%
    memory: Math.random() * 25 + 50, // 50-75%
    connections: Math.floor(Math.random() * 20) + 30, // 30-50
    iops: Math.floor(Math.random() * 1000) + 500 // 500-1500
  }))
];

const mockStorageData = [
  {
    databaseId: 'db-1',
    allocated: 250,
    used: 187,
    free: 63,
    utilization: 74.8
  },
  {
    databaseId: 'db-2',
    allocated: 100,
    used: 68,
    free: 32,
    utilization: 68.0
  },
  {
    databaseId: 'db-3',
    allocated: 50,
    used: 12,
    free: 38,
    utilization: 24.0
  },
  {
    databaseId: 'db-4',
    allocated: 25,
    used: 18,
    free: 7,
    utilization: 72.0
  }
];

module.exports = {
  mockUsers,
  mockDatabases,
  mockSlowQueries,
  mockMetrics,
  mockStorageData
};